
import java.util.*;

public class Test22 {
    public static void main(String[] args) {
        String sentence = "Hello, world! This is Java.";
        String longestWord = findLongestWord(sentence);
        System.out.println(longestWord); // 输出: "Hello"
    }

    public static String findLongestWord(String sentence) {
        String cleaned = sentence.replaceAll("[^a-zA-Z ]", "");
        String[] words = cleaned.split(" ");
        String longestWord = "";
        for (String word : words) {
            if (word.length() > longestWord.length()) {
                longestWord = word;
            }
        }
        return longestWord;
    }
}